import BaseAssetLoad from "./BaseAssetLoad";
import MsgDispatcher, { MsgType } from "../../Tool/MsgDispatcher";

export default class OppoAssetLoader extends BaseAssetLoad 
{
    
    public OnLoadFinished() 
    {
        
    }

    public OnLoadPregress(progress: number) 
    {
        MsgDispatcher.Send(MsgType.GameLoading,progress);
    }

    public LoadAsset(succss?:Function,fail?:Function,complete?:Function) 
    {
        console.log("Oppo LoadAsset");
        succss&&succss();
    }

    OppoLoadSubpackage(succss?:Function)
    {
        console.log("Oppo OppoLoadSubpackage");
        const loadcallback=  qg.loadSubpackage({
            name: 'res', // name 可以填 name 或者 root
            success: function() 
            {
                // 分包加载成功后通过 success 回调
                console.log("OppoLoadSubpackage success");
                succss&&succss();
            },
            fail: function() {
                // 分包加载失败通过 fail 回调
                console.log("OppoLoadSubpackage fail ");
                
            },complete:function(res){
                
                console.log("OppoLoadSubpackage complete");
            }
        });   
          
        loadcallback.onProgressUpdate(function(res){
            // 加载进度百分比
            var progress = res["progress"];
            // 下载数据
            var totalBytesWritten = res["totalBytesWritten"];
            // 总长度
            var totalBytesExpectedToWrite = res["totalBytesExpectedToWrite"];
        })
    }
}